home *** CD-ROM | disk | FTP | other *** search
- /****
- * CNeoBlob.h
- *
- * Persistent blob class.
- *
- ****/
- #pragma once /* Include this file only once */
- #ifndef __CNeoBlob__
- #define __CNeoBlob__ 1
-
- #include "NeoTypes.h"
- #include CNeoPersistNativeH
-
- class ENeoBlob {
- public:
- /** Instance Methods **/
- ENeoBlob(CNeoPersist *aContainer);
- ~ENeoBlob(void);
- static NeoBlob CacheMalloc(size_t aSize);
- long getFileLength(void) const;
- void add(void);
- void remove(void);
-
- /** I/O Methods **/
- void readObject(CNeoStream *aStream, const NeoTag aTag);
- void writeObject(CNeoStream *aStream, const NeoTag aTag);
- void update(CNeoPersist *aObject);
-
- /** Blob Management Methods **/
- NeoBlob getBlob(void);
- long getLength(void) const {return fLength;}
- NeoMark getMark(void) const {return fMark;}
- Boolean isBusy(void) const {return fBusy;}
- Boolean isDirty(void) const {return fDirty;}
- void setBlob(NeoBlob aBlob, const long aLength);
- void setBusy(const Boolean aBusy = TRUE) {fBusy = aBusy;}
- void setDirty(const Boolean aDirty = TRUE);
-
- /** Purge Methods **/
- Boolean isPurgeable(NeoSize *aNeeded) {return purge(aNeeded);}
- Boolean purge(NeoSize *aNeeded);
-
- #ifdef qNeoDebug
- /** Debugging Methods **/
- virtual const void *verify(const void *aValue) const;
- #endif
-
- /** Instance Variables **/
- protected:
- Boolean fDirty;
- Boolean fBusy;
- NeoMark fMark;
- long fLength;
- NeoBlob fBlob;
- CNeoPersist * fContainer;
- };
-
- class CNeoBlob : public CNeoPersistNative
- {
- public:
- /** Instance Methods **/
- CNeoBlob(void);
- static NeoBlob CacheMalloc(size_t aSize) {return ENeoBlob::CacheMalloc(aSize);}
- static CNeoPersist *New(void);
- virtual NeoID getClassID(void) const;
- virtual long getFileLength(void) const;
-
- /** I/O Methods **/
- virtual void readObject(CNeoStream *aStream, const NeoTag aTag);
- virtual void writeObject(CNeoStream *aStream, const NeoTag aTag);
- virtual void update(CNeoPersist *aObject);
-
- /** Persistence Methods **/
- virtual void add(void);
- virtual void remove(void);
-
- /** Blob Management Methods **/
- NeoBlob getBlob(void) {return fBlob.getBlob();}
- long getBlobLength(void) const {return fBlob.getLength();}
- NeoMark getBlobMark(void) const {return fBlob.getMark();}
- Boolean isBlobBusy(void) const {return fBlob.isBusy();}
- Boolean isBlobDirty(void) const {return fBlob.isDirty();}
- void setBlob(NeoBlob aBlob, const long aLength) {fBlob.setBlob(aBlob, aLength);}
- void setBlobBusy(const Boolean aBusy) {fBlob.setBusy(aBusy);}
- void setBlobDirty(const Boolean aDirty = TRUE) {fBlob.setDirty(aDirty);}
-
- /** Purge Methods **/
- virtual Boolean isPurgeable(NeoSize *aNeeded);
- virtual Boolean purge(NeoSize *aNeeded);
- Boolean purgeBlob(NeoSize *aNeeded) {return fBlob.purge(aNeeded);}
-
- protected:
- #ifdef qNeoDebug
- /** Debugging Methods **/
- virtual const void *verify(const void *aValue) const;
- #endif
-
- /** Instance Variables **/
- ENeoBlob fBlob;
- };
-
- enum {kENeoBlobFileLength = (sizeof(NeoMark) + sizeof(long))};
- enum {kNeoBlobFileLength = kNeoPersistFileLength + kENeoBlobFileLength};
-
- const NeoTag pBlobMark = Neo4CharConst('BB','mk');
- const NeoTag pBlobLength = Neo4CharConst('BB','ln');
- const NeoTag pBlobData = Neo4CharConst('BB','dt');
- #endif
-